from elasticsearch import Elasticsearch
 
es = Elasticsearch()
es.indices.create(index='news1', ignore=400)
 
data = {'title': '美国留给伊拉克的是个烂摊子吗', 'url': 'http://view.news.qq.com/zt2011/usa_iraq/index.htm'}
result = es.create(index='news1',doc_type='politics',id=1,body=data)
print(result)